package io.renren.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.renren.utils.Config;


public class Jdbc_digan {
	private static final Logger logger = LoggerFactory.getLogger(Jdbc_digan.class);
	private volatile static Jdbc_digan jdbc_digan;
	Connection dbcon1 = null;
	public static Jdbc_digan getsingleton() throws InstantiationException, IllegalAccessException, ClassNotFoundException
	{
		if(jdbc_digan == null)
		{
			synchronized (Jdbc_digan.class) {
				if(jdbc_digan == null)
				{
					jdbc_digan = new Jdbc_digan();
				}
			}
		}
		return jdbc_digan;
	}
	/*public Jdbc_digan() throws InstantiationException, IllegalAccessException, ClassNotFoundException{	
		if(dbcon1 == null)
		{
			dbcon1 = getDianGanConnection();
		}
	}*/
	public void closeConnect()
	{
		if(dbcon1 != null)
		{
			try {
				dbcon1.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	/*public Connection getDianGanConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
		Connection dbcon1 = null;
		String dburl = Config.getDburl();
		String user = Config.getDbUser();
		String pwd = Config.getDbPassword();
	
			
			try {
				Class.forName(Config.getDbDriverName()).newInstance();
				dbcon1=DriverManager.getConnection(Config.getDburl(),Config.getDbUser(),Config.getDbPassword());
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				logger.debug(e.getMessage());
				e.printStackTrace();
			}
			
		
		return dbcon1;
	}*/
}
